package com.test;

import java.io.IOException;
import java.io.InputStream;

/**
 * Created by 41579 on 2017/4/16.
 */
public class InterruptObj {
    Integer lock = 1;
    InputStream in;

    public InterruptObj(){}

    public InterruptObj(InputStream in){
        this.in = in;
    }

    public synchronized void execute() {
        System.out.println(Thread.currentThread().getName() + "：begin....");
        try {
            Thread.sleep(3000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + "：InterruptRunnable....");
    }


    public void execute2() {
        System.out.println(Thread.currentThread().getName() + "：begin....");
        try {
            in.read();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    public synchronized void execute3() {
        System.out.println(Thread.currentThread().getName() + "：begin....");
        try {
            Thread.sleep(15000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println(Thread.currentThread().getName() + "：InterruptRunnable....");
    }
}
